/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ function(module, exports, __webpack_require__) {

	var SelectDropDown = __webpack_require__(26);
	/*var SelectDropDown = UcsmyUI.SelectDropDown;*/
	var Root = React.createClass({displayName: "Root",
	    options:[
	        {
	            option: "下拉1"
	        },
	        {
	            option: "<div><img src='' alt=''>13546456454</div>",
	            value: "2",
	            disabled: true //不能选择
	        },
	        {
	            option: "下拉3",
	            value: "3",
	            disabled: true
	        },
	        {
	            option: "下拉4",
	            value: "4"
	        },
	        {
	            option: "下拉5",
	            value: "5"
	        }
	    ],
	    test:function(){
	        var val = this.refs.test.getCurrentSelect();
	        console.log(val);
	    },
	    onchange:function(v){
	        console.log(v)
	    },
	    componentDidMount:function(){

	    },
	    render:function(){
	        return (
	            React.createElement("div", null, 
	                React.createElement(SelectDropDown, {options: this.options, ref: "test", onChange: this.onchange.bind(this)}), 
	                React.createElement(SelectDropDown, {options: this.options}), 
	                React.createElement(SelectDropDown, {options: this.options}), 
	                React.createElement("button", {onclick: this.test.bind(this)}, "获取第一项当前选择项")
	                /*<button onclick={this.test.bind(this)}>设置当前选择项</button>*/
	            )
	        )
	    }
	});
	ReactDOM.render(React.createElement(Root, null), document.getElementById('main'));


/***/ },

/***/ 26:
/***/ function(module, exports) {

	/**
	 * Created by DuHuiling on 2017/2/24.
	 */
	var closeOpen = function(){
	    var _open = document.getElementsByClassName('open')[0];
	    if(_open){
	        var _classArr = _open.className.split(" ");
	        for(var i in _classArr){
	            if(_classArr[i] == "open"){
	                _classArr.splice(i,1);
	            }
	        }
	        var _className = _classArr.join(" ");
	        _open.className = _className;
	    }
	}
	window.onclick = function(){
	    closeOpen();
	};

	var SelectDropDown = React.createClass({displayName: "SelectDropDown",
	    getDefaultProps: function () {
	        return {
	            id:"",
	            value: "",//默认初始值
	            className: "",
	            type: "", //三种类型，bank,search
	            showNum: "",
	            options: "",
	            defaultValue: "请选择",
	            searchButton: "",
	            placeholder: "",
	            inputChange: "",//搜索时输入框回调
	            buttonClick: "",//搜索时按钮回调
	            _dmid: new UDM({}).dmbind /*为每个 select-dropdown 创建udmid*/
	        }
	    },
	    getInitialState:function(){
	        return{
	            currentIdx:this.props.defaultValue,
	            currentValue:0,
	            _className:this.props.className ? "ucs-select-dropdown "+ this.props.className : "ucs-select-dropdown"
	        }
	    },
	    _toggle:function(ref,e){
	        var _current = this.refs[this.props._dmid];

	        if(e && e.stopPropagation){
	            //因此它支持W3C的stopPropagation()方法
	            e.stopPropagation();
	        }else{
	            //否则我们使用ie的方法来取消事件冒泡
	            window.event.cancelBubble = true;
	        }
	        this.setState({
	            _className:this._toggleOpen(_current.className)
	        })
	    },
	    _toggleOpen: function(_class){
	        var _classList = _class.split(" ");
	        var j = 0;
	        for(var i=0; i<_classList.length;i++){
	            if(_classList[i] == "open"){
	                j = i;
	            }
	        }
	        if(j){
	            _classList.splice(j,1);
	        }else{
	            _classList.push('open');
	        }
	        _classList = _classList.join(" ");
	        return _classList;
	    },
	    _select:function(idx,val,ref){
	        var _node = this.refs[ref],
	            _input = this.refs[ref + '-control'];
	        _node.className = this._toggleOpen(_node.className);
	        _input.innerHTML = this.props.options[idx].option;

	        this.state.currentIdx = idx;
	        if(val.value){
	            this.state.currentValue = val.value;
	        }else{
	            this.state.currentValue = idx;
	        }

	        var _v = this.getCurrentSelect();
	        this.props.onChange ? this.props.onChange(_v) : "";
	    },
	    getCurrentSelect:function(){
	        return {
	            index:Number(this.state.currentIdx),
	            value:this.state.currentValue
	        }
	    },
	    /*下拉选项列表*/
	    selectList: function(){
	        var _lis = [],_that = this;
	        for(var i=0; i<this.props.options.length;i++){
	            (function(j,val,ref){
	                _lis.push(
	                    React.createElement("li", {onclick: _that._select.bind(_that,j,val,ref)}, 
	                        _that.props.options[j].option
	                    )
	                );
	            })(i,this.props.options[i],this.props._dmid);
	        }
	        return React.createElement("ul", null, _lis)
	    },
	    render:function(){
	        /*判断defaultValue是否是数字，“是”则代表默认显示第几个选项*/
	        var defaultValue = this.state.currentIdx,
	            _dom;
	        if(typeof defaultValue == "number"){
	            _dom = this.props.options[defaultValue].option;
	        }else{
	            _dom = defaultValue;
	        }

	        return (
	            React.createElement("div", {className: this.state._className, ref: this.props._dmid}, 
	                React.createElement("div", {className: "ucs-select-control", ref: this.props._dmid + '-select-click', onclick: this._toggle.bind(this,this.props._dmid + '-select-click')}, 
	                    React.createElement("div", {className: "ucs-input", ref: this.props._dmid + '-control'}, _dom), 
	                    React.createElement("span", {className: "ucs-icon"})
	                ), 
	                React.createElement("div", {className: "ucs-dropdown"}, 
	                    React.createElement("div", {className: "ucs-dropdown-border"}, 
	                         this.selectList.bind(this)() 
	                    )
	                )
	            )
	        )
	    }
	});
	module.exports = SelectDropDown;

/***/ }

/******/ });